package com.heima.wemedia;

import okhttp3.*;
import org.json.JSONObject;

import java.io.*;

class Sample {

    static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();

    public static void main(String []args) throws IOException{
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "");
        Request request = new Request.Builder()
                .url("https://aip.baidubce.com/oauth/2.0/token?client_id=I1LtptKnbv61FE8nDsGTfija" +
                        "&client_secret=MfKvOQXwuwh3cd1VdDZxKeLfmMgpWkf2&grant_type=client_credentials")
                .method("POST", body)
                .addHeader("Content-Type", "application/json")
                .addHeader("Accept", "application/json")
                .build();
        Response response = HTTP_CLIENT.newCall(request).execute();
        System.out.println(response.body().string());  //"access_token":"24.1f22c11cb63da28f0ef3aa1edadc630b.2592000.1689051073.282335-34674036" 有效期30天

    }
}